#include "main.h"



int add(int a,int b)
{
    int c = 0;
    return c=a+b;
}

void my_print(void)
{
    printf("hello world\r\n");
}



void jin (void)
{   int n=9; 
    int i,j,k;
    for (i=1;i<=n;i++)
    {
        for(j=1;j<=n-i;j++)
        { 
            printf(" ");}
                for (k=1;k<=2*i-1;k++){

                    printf("*");
                }
                 printf("\n");
       
            }
            
        
     
    }
void cheng (void)
{ for(int i=1;i<=9;i++)
    {   for(int j=1;j<=i;j++)
            {   printf("%d*%d=%2d ",j,i,j*i);



            }
        printf("\n");


                }


}
void chengji(int b[], int n) {
    printf("输入%d个成绩（0-100）：\n", n);
    for (int i = 0; i < n; i++) {
        do {
            scanf("%d", &b[i]);
            if (b[i] < 0 || b[i] > 100)
                printf("无效重新输入：");
        } while (b[i] < 0 || b[i] > 100);
    }
}

//计算平均分
float pingjun(int b[], int n) {
    int sum = 0;
    for (int i = 0; i < n; i++) sum += b[i];
    return (float)sum / n; 
}

//最高分
int Max(int b[], int n) {
    int max = b[0];
    for (int i = 1; i < n; i++)
        if (b[i] > max) max = b[i];
    return max;
}


int main(int argc,char *argv[])
{
    //int ret = 0;
    //int i=1,j=2;
   // printf("i:%d,j:%d,i+j=%d\r\n",i,j,add(i,j));
   // my_print();
    //jin();
   // cheng();
    int a, b[20]; 
    printf("学生人数（最多20人）：");
    scanf("%d", &a);

    chengji(b, a);
    printf("平均分：%.1f，最高分：%d\n", pingjun(b, a), Max(b, a));
    return 0;
}
